import pandas as pd
from pandasai import Agent
from pandasai.llm.openai import OpenAI

# 读取 CSV 文件
df = pd.read_csv("D:\stock_qiqi..csv")
# 将 日期列转换为日期时间格式
df['日期'] = pd.to_datetime(df['日期'])
# 设置 日期列为索引
df.set_index('日期', inplace=True)

# 配置 Deepseek 模型
OpenAI._supported_chat_models.append('deepseek-chat')
llm_openai = OpenAI(
api_base='https://api.deepseek.com/v1',
api_token='sk-9da86cb4837847988ab8aac94ed592f6',
model='deepseek-chat'
)

# 创建 Agent
agent = Agent(dfs=[df], config={"llm": llm_openai})

# 执行查询
response = agent.chat("输出股票数据")
print(response)